
var app = getApp(),
  fn = app.fn;

function URLencode(sStr) {
  return escape(sStr).replace(/\+/g, '%2B');
}


Page({
  data: {
    login: [],
    userinfo: [],
    userCode: '',
    isLogin: false,
    sessionKey: '',
    iv: '',
    encryptedData: '',
    orderType: [
 
    ],
    mine: [
    
    ],
  },

  onLoad: function (options) {
  
    this.setData({
      login: app.globalData.userInfo,
      userinfo: app.globalData.wxUserInfo,
    });
  
  },


  onPullDownRefresh: function () {

  },

  orderTypeClick: function (e) {
    var that = this;

    if (that.data.login == null) {
     
    } else {
      var id = e.currentTarget.dataset.id,
        url;
      switch (id) {
        case '0':  //全部订单
          url = '../orderList/orderList?orderStatus=0';
          break;
        case '1':  //待付款
          url = '../orderList/orderList?orderStatus=1';
          break;
        case '2':  //待发货
          url = '../orderList/orderList?orderStatus=2';
          break;
        case '3':  //待收货
          url = '../orderList/orderList?orderStatus=3';
          break;
        case '4':  //已完成
          url = '../orderList/orderList?orderStatus=4';
          break;
      }
      wx.navigateTo({
        url: url
      })
    }
  },

  loginClick: function () {
    // var url;
    // url = '../bundLing/bundLing';
    // wx.navigateTo({
    //   url: url
    // })
  },

  mineClick: function (e) {
    var that = this;

    if (that.data.login == null) {
      // var url;
      // url = '../bundLing/bundLing';
      // wx.navigateTo({
      //   url: url
      // })
    } else {
      var id = e.currentTarget.dataset.id,
        url;
      switch (id) {
        case '1':  // 优惠劵
          url = '../coupon/coupon?block=0&prices=';
          break;
        case '2':  // 收藏
          url = '../collection/collection';
          break;
        case '3':  // 足迹
          url = '../footprint/footprint';
          break;
        case '4':  // 地址
          url = '../addressList/addressList';
          break;
        case '5':   // 客服
          url = '../customer/customer';
          break;
      }
      wx.navigateTo({
        url: url
      })
    }

  },

  //设置
  setClick : function(){
    wx.openSetting({
      success(res) {
        console.log(res.authSetting)
        // res.authSetting = {
        //   "scope.userInfo": true,
        //   "scope.userLocation": true
        // }
      }
    })
  }


})